<?php

namespace App\Admin\Renderable;

use App\Models\Firm;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class FirmTable extends  LazyRenderable
{

    public function grid(): Grid
    {
        // 获取ID

        return Grid::make(new Firm(['profession:id,name','category:id,name']),function (Grid $grid){
            $grid->disableActions();
            $grid->showRowSelector();
            $grid->column('id')->sortable();
            $grid->column('profession.name','行业');
            $grid->column('category.name','企业类型');
            $grid->column('name','企业名称');
            $grid->column('area','所在区域');
            $grid->column('corporate_name','法人姓名');
            $grid->column('corporate_phone','法人手机号')->copyable();


            $grid->filter(function (Grid\Filter $filter){
                $filter->like('name',)->width(3);
                $filter->equal('corporate_phone','法人手机号')->width(3);
            });
        });
    }

}
